怎麼檢查 object 是不是空的?


Posted by Rich on 2021-09-12

有時候會有這種需求,這次解決的幫手是:

let obj = {}
if (Object.keys(obj).length === 0) //true

怕忘記,紀錄一下。










Related Posts

[JS Behind The Scene] prototype chain-new 在背後到底做了甚麼?

[JS Behind The Scene] prototype chain-new 在背後到底做了甚麼?

筆記:What the heck is the event loop anyway | Philip Roberts | JSConf EU

筆記:What the heck is the event loop anyway | Philip Roberts | JSConf EU

[心得] - Final Project 實作心得

[心得] - Final Project 實作心得


Comments